package com.txby.wxyyApi.component.interceptor;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

@WebListener
public class IndexListener implements ServletContextListener {
	private static Logger log = Logger.getLogger(IndexListener.class);

	public void contextInitialized(ServletContextEvent servletContextEvent) {
		ServletContext servletContext = servletContextEvent.getServletContext();
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
		// 将数据放到缓存中。
		servletContext.setAttribute("allNotLeafNodeList", "AAAAAAAAAAAAAAAAAAA");
		servletContextEvent.getServletContext().removeAttribute("allNotLeafNodeList");
		
		System.out.println(servletContext.getAttribute("allNotLeafNodeList"));
	}

	public void contextDestroyed(ServletContextEvent servletContextEvent) {
		System.out.println("关闭信息！");
	}
	

}